Part2: Lets use some CAOS to inject an object....
[please turn word wrap off!]


Caos is more or less allong the lines of four letter command, followed by variables, etc...
But I'm going to start of somewhere a little unexpected and shoot right into some CAOS,
based mainy on the idea that this approach has worked before.

Someone once said "Teach me how to do some CAOS stuff"  (yeah, hi shane! heheh)
I replied with

new: simp 2 8 2 "caos stuff" 0 0 12.


Undoubtedly, you'll have seen something really similar to this if you've ever looked at the
.cos code in the bootstrap folder, or from another download somewhere. If you've not seen
it, and you're looking a little confused *pokes* , read thru, it all makes sense!

What we're telling the game to do is make a new agent/object...

	NEW:    This tells the game, "yay, lets add something new", and the variables following this are
	what tells the game what exactly it's making.

	SIMP   Tells the game this is going to be a simple object, not a norn, not a compound object, not a 	
	vehicle, but er.. something like an apple, or a fish or a simple machine.

	2 8 2 : To be more precise, the part 2 8 2  tells the game what exactly it is. Since  2 8 2 , is always 	
	an apple.	These 	three numbers are known as the classifier (well I call them that), and in practice, 		
	you'll see they are a good idea, and that they make a lot of sense.. for example.

		2 - Tells the game it's amongst the class  "Living stuff"
		8 - Telss the game this is a fruit.
		2 - Tells the game, that this is an apple more specifically.

		These are known as
		
		Family     (living stuff)
		Genus     (fruits)
		Species   (apple).
		
		Other examples might be umm...  
		[creatue)   (norn) (species 1)  or as a classifier ( 4 1 1 )   - A norn
		(creature)  (grendel)  (species 2)  or as a classifer (4 2 2 ) - A grendel
		(living stuff) (fish) (shark)  or as a classifier ( 2 25 2 ) - A rainbow sharkling
		
The next part of "new: simp 2 8 2 "caos stuff" 0 0 12" , would be

	"caos stuff" this is the part that tells the game where exactly it's loading the image from, i.e.
	the apple is  "apple.s16" in the creatures \ images folder, or the cheese machine is
	"infinite_cheese_machine".
	This refers to the file "infinite_cheese_machine.s16" in the same folder.

And the last three numebers here:

	Image Count  , First Image  and Plane.

	Image count tells the game how many images are used for this object, i.e. to animate it.

	First image tells the game where in the .s16 file (ie apples.s16) the first image this object 
	uses is.
	I.e. The corridor doors' images are all contained within the one file... doors.s16, and the 
	nursery door uses sprites 98 to 119 ... i.e 21 sprites for "image count" and  98 for "first image".

	Plane. Think of all the objects in the world as being a collage for a moment. I.e. with norns near 
	the front, doors behind norns, lift bars appearing in front of norns etc. This is due to the layering 
	system creatures uses. The higher the number  (reaching  amaximum of 9000) the closer it is to 
	the camera. The background has a plane of 0, so anything else must be somewhere inbetween.



Lets review:

"new: simp 2 8 2 "caos stuff" 0 0 12"

	*STOP!
Please don't continue untill you can explain more or less what all of this means, and how it relates to the 
games. I prommise though, this is one of the hardest commands of the lot!


Some more Caos:

Now you've injected your new caos stuff  .. err, please don't try to inject that, there's a "inject a cheese"
 tutorial coming up in just a min.. It will be functional :).. anyway, lets pretend you now have a new caos 
stuff injected.. you'll want to start giving it some properties!

For example, can you carry your new stuff? Can it be eaten?

ATTR:
	The first of these usually is the ATTR.  
	Attr, or "Atrributes" is a number which you can give the object to figure out what properties it has. 
	Look at the following values:
	
	1 -Carryable -Can be picked up by things other than creatures, vehicles and the pointer. 
	2 -Mouseable -Can be picked up by the mouse. 
	4 -Activateable -Can be activated using the mouse - otherwise CLAC and CLIK style events don't get sent when you click on the agent. 
	8 -Greedy -Cabin When set on a vehicle, it will automatically pick up things dropped in its cabin. 
	16 -Invisible -Creatures don't see you - applies to ESEE and STAR on creatures, as well as internal creature code. 
	32 -Floatable -Agent floats relative to the screen. Move it with FLTO. If you call FREL, the agent will float relative to another agent instead of the screen. 
	64 -Suffer Collisions -Will collide with room boundaries, according to its PERM. 
	128 -Suffer Physics -Agent falls with proper physics, including gravity, air resistance and friction. Otherwise, it simply moves with velocity. 
	256 -Camera Shy Agent can't be seen on a remote camera (PAT: CMRA) or photograph (SNAP). For vehicles, the contents is shy as well. 
	512 -Open Air Cabin 
	
	This is actually much less confusing than it lookes, for, say we want our "new stuff" to be carryble ,
	 mousable, and activateable, we just add 1+2+4  ,  to give 7...
	
	Now we say 
	
		ATTR 7

	And the game will calculate automatically that your new object is carryable , mousable and activateable..
	 Real clever huh? You don't have to do the hard part.



BHVR:
	How about the way creatures can interact, this is called the Behabiour, or BHVR

	1 -Activate 1 -Creature can activate 1 this agent. 
	2 -Activate 2 -Creature can activate 2 this agent. 
	4 -Deactivate -Creature can deactivate this agent. 
	8 -Hit -Creature can hit this agent. 
	16 -Eat -Creature can eat this agent. 
	32 -Pick Up -Creature can pick up this agent. 

	Likewise, say we want creatures to be able to pick up and eat this object, we give it:
	16 + 32... and get 48...

	 BHVR 48

	Once again, no math required really... Well, it's all simple stuff unless you're trying to work out 
	backwards what Attr 198 is in your head :S  (you can figure it out with the devthing easily)

	And finally you'll want to give the object some physics...

	elas : this controls the elasticity (bouncie bouncieness) of the object.. I.e. rubber ball versus rock.
	
	accg: acceleration due to gravity OR  weight in other words.... Either way, how fast it falls!
	
	fric : friction of the object.. I.e. if it has high friction it won't slide down a slope so fast
	
	aero: Aerodynamics .. or how fast the object will fly if you pick it up and throw it :P
	
	perm: A little more complicated, this is used to govern the different levels, and different depths
		within the game and is why some apples will land on the wooden walkway , while some will fall
		all the way to the norn garden. More later.

For our caos stuff, we might want to use:

ELAS 30
ACCG 5
AERO 5
FRIC 100
PERM 60


And finally, three more you'll need to know for the upcoming example:

	INST : causes whatever script you've injected into the world to execute (run) immediately, i.e.
		the game will run this whole script before continuing at all. If it's a big script, there might be a 
		considerable pause in the game.. If not, then eh... who cares :)

	MVTO x , y  : Move to the X,Y coordinate, i.e. in C3,   mvto 700 750, would move the current object
		into the norn nursery area.

	ENDM : Signals the end of the current script. :)



A note on scripts:

	Every object has an install script, and other scripts based on it's attributes and behaviour. I.e.
	Was it clicked? was it eaten? was it picked up?
	
	The install script is run once... to inject the object, while the other scripts are run as necessary, i.e.
	once your cheese is eaten.
	
	When you are isntalling a brand new object, i.e. one from the internet, chances are it will need to be 
	clicked, carried, activated, etc in some way, and it will come with some scripts governing this, but if
	for example we're injecting a cheese... The scripts are already there, so... There's no point making
	new ones. You'll see later.

For now, we're going to inject a cheese (Creatures3 Example)
here's some code:

	inst
	new: simp 2 11 2 "infinite_cheese_machine" 2 44 8000
	attr 195 
	bhvr 48 
	perm 64 
	elas 40 
	accg 10 
	aero 5 
	fric 20 
	mvto 700 700
	endm


And there you have it,  fresh cheese is injected straight into the game! yay!
Hey, aren't you proud? You should know more or less what that means now!


Run through this tutorial Again, It's a little big, but you'll be glad you did no doubt :)



_______________________________________________
First Edition.. I.e. nobody has commented on this yet! Feel free to do so on the albia200.com
forums, or by email.
Should you wish to reproduce this file in whole or part, please include this message somewhere
linking to the original download site:   wopsy.wopstick.com/jcs Thanks :)







